﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using Liger.Generate;

public class DbTemplateHepler
{
    public static string GetClassName(string name)
    {
        return name.Replace(" ", "").Replace("_", "").Trim();
    }

    public static string GetCSharpType(ColumnBase column)
    {
        StringBuilder str = new StringBuilder();
        switch (column.DataTypeName.ToLower())
        {
            case "text":
            case "ntext":
            case "nvarchar":
            case "memo":
                str.Append("string"); 
                break;
            case "int":
            case "long":
                str.Append("int");
                if (column.IsNullable)
                    str.Append("?");
                break;
            case "image":
            case "ole object":
            case "oleobject":
                str.Append("object");
                break;
            case "datetime":
                str.Append("DateTime");
                if (column.IsNullable)
                    str.Append("?");
                break;
            default:
                str.Append("string");
                break;
        }
        return str.ToString();
    }
}